package com.java3_3;

import java.util.Scanner;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class java3_3 {
    //    //    //    public static void main(String[] args) {
//////        //递归 -- 在函数内部自己调用自己
//////        //main();
//////        //注意的四个点
//////        //求n！
//////        int n;
//////        Scanner sc = new Scanner(System.in);
//////        System.out.print("请输入一个整数: ");
//////        n = sc.nextInt();
//////        int ret = Fun(n);
//////        System.out.println(ret);
//////
//////    }
//////    public static int Fun(int number){
//////        if(number == 0 || number == 1){
//////            return 1;
//////        }
//////        else{
//////            return number * Fun(number - 1);
//////        }
//////    }
//////    public static void main(String[] args) {
//////        //斐波那契数列
//////        int n;
//////        Scanner sc = new Scanner(System.in);
//////        System.out.print("请输入一个整数： ");
//////        int fib = Fib(sc.nextInt());
//////        System.out.println(fib);
//////
//////    }
//////
//////    //求第n个斐波那契数字
//////    public static int Fib(int num) {
//////        if (num <= 2)
//////            return 1;
//////        else
//////            return Fib(num - 1) + Fib(num - 2);
//////    }
////    //上台阶问题
//////    public static void main(String[] args) {
//////        int n;
//////        Scanner sc = new Scanner(System.in);
//////        System.out.print("请输入您所上的台阶数： ");
//////        System.out.println(Fun(sc.nextInt()));
//////
//////    }
//////    //上n阶台阶的走法个数
//////    public static int Fun(int number){
//////        if(number == 1)
//////            return 1;
//////        else if (number == 2)
//////            return 2;
//////        else
//////            return Fun(number-1)+Fun(number-2);
//////    }
////    //递归经典问题 -- 汉诺塔
////    public static void main(String[] args) {
////        char a = 'A';
////        char b = 'B';
////        char c = 'C';
////        System.out.println("汉诺塔问题~~~");
////        int n;
////        Scanner sc = new Scanner(System.in);
////        hanNuoTa(sc.nextInt(),a,b,c);
////
////    }
////
////    public static void move(int n, char begin, char end) {
////        System.out.println("将第" + n + "个盘子从" + begin + "移动到------------->" + end);
////    }
////    public static void hanNuoTa(int n,char A,char B,char C){
////        if(n == 1)
////            move(n,A,C);
////        else{
////            hanNuoTa(n-1,A,C,B);
////            move(n,A,C);
////            hanNuoTa(n-1,B,A,C);
////        }
////    }
////    public static void main(String[] args) {
//////        System.out.println(MyEnumerate.SPRING.toString());
//////        System.out.println(MyEnumerate.AUTUMN.toString());
////
//////        System.out.println(Enumerate2.SPRING.toString());
//////        System.out.println(Enumerate2.WINTER.toString());
////
////        //直接使用toString是枚举类对象的名称（可重写）
//////        System.out.println(Enumerate2.SUMMER.toString());
////
//////        System.out.println(Enumerate2.SPRING.name());
////
//////        Enumerate2 autumn = Enumerate2.valueOf("AUTUMN");
//////        System.out.println(autumn.getName());
//////
//////        //返回值是一个数组
//////        Enumerate2[] values = Enumerate2.values();
//////        for (int i = 0; i < values.length; i++) {
//////            System.out.println(values[i].name());
//////        }
//////
//////        int ordinal = Enumerate2.valueOf("WINTER").ordinal();
//////        System.out.println(ordinal);
////
////
////        Enumerate2.SPRING.show();
////        Enumerate2.AUTUMN.show();
////
////        Enumerate2[] values = Enumerate2.values();
////        System.out.println(values);
////    }
//    public static void main(String[] args) {
//        Demo1 demo1 = Demo1.getDemo1();
//        Demo2 demo2 = Demo2.getDemo2();
//
//
//
//    }
//    public static void main(String[] args) {
//        String s1 = String.valueOf(1);
//        String s2 = String.valueOf(1);
//        System.out.println(s1 == s2);
//
//        Integer i1 = 1;
//        Integer i2 = 1;
//        Integer.valueOf();
//        Integer.toString()
//        System.out.println(i1 == i2);
//
//        Character c1 = 'a';
//        Character c2 = 'a';
//        Character.valueOf()
//        System.out.println(c1 == c2);
//
//        Boolean.valueOf()
//    }
//    public static void main(String[] args) {
////        String s1 = String.valueOf(1);
////        String s2 = String.valueOf(1);
////        System.out.println(s1 == s2);
//
////        Integer i = 100;
////        System.out.println(i.toString());
////        System.out.println(i);
//
////        MyInteger myInteger = new MyInteger(100);
////        System.out.println(myInteger);
//
//        //类型的转换
//        //基本数据类型 -> 包装类
//        //(1)创建对象
////        Character character;
////        character = new Character('z');
//
//        //(2)转化方法
////        Character c = Character.valueOf('z');
////        System.out.println(c);
//
//        //(3)自动转化
////        Character c = 'A';
////        System.out.println(c);
//
//        //包装类 -> 基本数据类型
//        //（1）转化的方法
////        Integer i = 1000;
////        int i1 = i.intValue();
////        System.out.println(i1);
//
//        //(2)自动转化
////        Integer i = 1000;
////        int i1 = i;
////        System.out.println(i1);
//
//        //与String类型的转化
//        //(1)使用valueOf（）方法
////        Integer i = 2000;
////        String s = String.valueOf(100);
////        String s1 = String.valueOf(i);
////        System.out.println(s);
////        System.out.println(s1);
//
//        //(2)+""
////        Integer i = 100;
////        String s1 = 100+"";
////        String s2 = i+"";
////        System.out.println(s1);
////        System.out.println(s2);
//
//        //String类型转化为包装类
////        String str = "520";
////        int i = Integer.parseInt(str);
////        System.out.println(i);
//
////        String str= "3.14159";
////        System.out.println(Double.parseDouble(str));
//
//        Integer i = Integer.valueOf("520");
//        System.out.println(i);
//
//        Boolean b = Boolean.valueOf("faoj");
//        System.out.println(b);
//
//        Double d = Double.valueOf("3.14");
//        System.out.println(d);
//
//    }
    public static void main(String[] args) {
        //两种补充的方法
        //线程安全

//        new Thread(){
//            @Override
//            public void run() {
//                Demo3 demo3 = Demo3.getDemo3();
//                System.out.println(demo3.toString());
//            }
//        }.start();

        FinishCallable finishCallable = new FinishCallable();
        FutureTask futureTask = new FutureTask(finishCallable);
        Thread thread = new Thread(futureTask);
        thread.start();

        try {
            Object o = futureTask.get();
            System.out.println(o);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }

    }


}
